package com.hsc.yalebao.tabMine;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
import com.google.gson.Gson;
import com.hsc.yalebao.base.ActivityStack;
import com.hsc.yalebao.base.BaseActivity;
import com.hsc.yalebao.base.CustomApplication;
import com.hsc.yalebao.base.MainActivity;
import com.hsc.yalebao.http.AppConstants;
import com.hsc.yalebao.http.RequestNet;
import com.hsc.yalebao.model.BaseDataObject;
import com.hsc.yalebao.model.DrawmoneyBean;
import com.hsc.yalebao.model.GetDrawTimesBean;
import com.hsc.yalebao.model.UserBaseBean;
import com.hsc.yalebao.tools.UiUtil;
import com.hsc.yalebao.weight.LogUtils;
import com.hsc.yalebao.weight.MyDialog1;
import com.zhy.http.okhttp.callback.StringCallback;
import java.text.DecimalFormat;
import java.util.HashMap;
import okhttp3.Call;

public class TiXianActivity extends BaseActivity
{
  private String TAG = "TiXianActivity";
  private TextView bank_name;
  private TextView bank_number;
  private ImageView btn_tixian;
  private Context context;
  private TextView et_leave_money;
  private String guid = "";
  private ImageView iv_title_right;
  private int memberid;
  private MyDialog1 myDialog1;
  View.OnClickListener onClickListener = new View.OnClickListener()
  {
    public void onClick(View paramAnonymousView)
    {
      switch (paramAnonymousView.getId())
      {
      case 2131099704:
      default:
        return;
      case 2131099699:
        TiXianActivity.this.closeWindowSoftInput(TiXianActivity.this.withdraw_money);
        TiXianActivity.this.closeWindowSoftInput(TiXianActivity.this.withdraw_password);
        CustomApplication.app.finishActivity(TiXianActivity.this);
        return;
      case 2131099982:
      }
      TiXianActivity.this.checkoutdata();
    }
  };
  private String paypass;
  private String result = "";
  private int shurujine;
  private TextWatcher textWatcher = new TextWatcher()
  {
    public void afterTextChanged(Editable paramAnonymousEditable)
    {
    }

    public void beforeTextChanged(CharSequence paramAnonymousCharSequence, int paramAnonymousInt1, int paramAnonymousInt2, int paramAnonymousInt3)
    {
    }

    public void onTextChanged(CharSequence paramAnonymousCharSequence, int paramAnonymousInt1, int paramAnonymousInt2, int paramAnonymousInt3)
    {
      String str = TiXianActivity.this.withdraw_money.getText().toString();
      TiXianActivity.this.usermoeney = Double.valueOf(TiXianActivity.this.result).doubleValue();
      try
      {
        int i = 3 + str.length();
        int j = TiXianActivity.this.result.length();
        int k = Integer.parseInt(str);
        int m = (int)TiXianActivity.this.usermoeney;
        if ((i > j) || (k > m))
        {
          UiUtil.showToast(TiXianActivity.this.context, "提现金额已超过您的账户余额");
          TiXianActivity.this.withdraw_money.setText((int)TiXianActivity.this.usermoeney);
        }
        return;
      }
      catch (NumberFormatException localNumberFormatException)
      {
        localNumberFormatException.printStackTrace();
        return;
      }
      catch (Exception localException)
      {
        localException.printStackTrace();
      }
    }
  };
  private TextView tv_add_car;
  private TextView tv_now_have_time;
  private TextView tv_one_day_time;
  private TextView tv_shouxu;
  private TextView user_name;
  private double usermoeney;
  private View view_title;
  private EditText withdraw_money;
  private EditText withdraw_password;
  private String withdrawmoney;
  private String withdrawpassword;
  private int zhanghuyue;

  private void checkoutdata()
  {
    this.withdrawmoney = this.withdraw_money.getText().toString();
    this.withdrawpassword = this.withdraw_password.getText().toString();
    try
    {
      this.usermoeney = Double.valueOf(this.result).doubleValue();
      this.shurujine = Integer.parseInt(this.withdrawmoney);
      if (this.withdrawmoney.isEmpty())
      {
        ShowDialog1("请输入您的提现金额");
        return;
      }
    }
    catch (Exception localException)
    {
      while (true)
        localException.printStackTrace();
      if (this.shurujine < 100)
      {
        ShowDialog1("最低请提现100元宝");
        return;
      }
      if (this.shurujine > this.usermoeney)
      {
        ShowDialog1("提现金额已超过您的账户余额");
        return;
      }
      if ("".equals(this.withdrawpassword))
      {
        ShowDialog1("请输入您的提现密码");
        return;
      }
      withdrawrequest();
    }
  }

  private void setTiXianBtnIsEnable(boolean paramBoolean)
  {
    if (paramBoolean)
      this.btn_tixian.setBackgroundResource(2130838289);
    while (true)
    {
      this.btn_tixian.setEnabled(paramBoolean);
      return;
      this.btn_tixian.setBackgroundResource(2130838023);
    }
  }

  private void withdrawrequest()
  {
    if (CustomApplication.app.userBaseBean != null)
      this.memberid = CustomApplication.app.userBaseBean.getMemberid();
    HashMap localHashMap = new HashMap();
    localHashMap.put("memberid", this.memberid);
    localHashMap.put("Password", this.withdrawpassword);
    localHashMap.put("drawmoney", this.withdrawmoney);
    LogUtils.d(this.TAG, "URL:" + AppConstants.URL_GET_DRAWMONEY);
    setTiXianBtnIsEnable(false);
    RequestNet.get(this.context, AppConstants.URL_GET_DRAWMONEY, localHashMap, new StringCallback()
    {
      public void onError(Call paramAnonymousCall, Exception paramAnonymousException)
      {
        LogUtils.e(TiXianActivity.this.TAG, "获取失败,获取提现记录:" + paramAnonymousException);
        TiXianActivity.this.setTiXianBtnIsEnable(true);
      }

      public void onResponse(String paramAnonymousString)
      {
        TiXianActivity.this.setTiXianBtnIsEnable(true);
        if (UiUtil.IsValueEmpty(paramAnonymousString))
          LogUtils.d(TiXianActivity.this.TAG, "为空时result:" + paramAnonymousString);
        DrawmoneyBean localDrawmoneyBean;
        do
        {
          return;
          Gson localGson = new Gson();
          try
          {
            localDrawmoneyBean = (DrawmoneyBean)localGson.fromJson(paramAnonymousString, DrawmoneyBean.class);
            if (localDrawmoneyBean == null)
            {
              LogUtils.e(TiXianActivity.this.TAG, "drawmoneyBean，获取失败");
              return;
            }
          }
          catch (Exception localException)
          {
            while (true)
            {
              localException.printStackTrace();
              localDrawmoneyBean = null;
            }
            if (localDrawmoneyBean.getFlag() == 0)
            {
              TiXianActivity.this.ShowDialog1(localDrawmoneyBean.getMsg());
              return;
            }
            if (localDrawmoneyBean.getFlag() == -2)
            {
              TiXianActivity.this.showDownWireDialog();
              return;
            }
            if (localDrawmoneyBean.getFlag() == -3)
            {
              TiXianActivity.this.ShowFengjinDialog();
              return;
            }
            if (localDrawmoneyBean.getFlag() == -4)
            {
              TiXianActivity.activityStack.backToMain(MainActivity.class, TiXianActivity.this.context);
              return;
            }
          }
        }
        while (localDrawmoneyBean.getFlag() != 1);
        TiXianActivity.this.myDialog1.setMessage(localDrawmoneyBean.getMsg());
        TiXianActivity.this.withdraw_money.setText("");
        TiXianActivity.this.withdraw_password.setText("");
        TiXianActivity.this.myDialog1.show();
        TiXianActivity.this.myDialog1.btn_confirm.setOnClickListener(new View.OnClickListener()
        {
          public void onClick(View paramAnonymous2View)
          {
            TiXianActivity.this.myDialog1.dismiss();
            TiXianActivity.this.getUserAmount();
            TiXianActivity.this.GetDrawTimes();
          }
        });
      }
    });
  }

  public void GetDrawTimes()
  {
    if (CustomApplication.app.userBaseBean != null)
      this.memberid = CustomApplication.app.userBaseBean.getMemberid();
    HashMap localHashMap = new HashMap();
    localHashMap.put("memberid", this.memberid);
    LogUtils.d(this.TAG, "URL:" + AppConstants.URL_GET_GETDRAWTIMES);
    RequestNet.get(this.context, AppConstants.URL_GET_GETDRAWTIMES, localHashMap, new StringCallback()
    {
      public void onError(Call paramAnonymousCall, Exception paramAnonymousException)
      {
        LogUtils.e(TiXianActivity.this.TAG, "获取用户提现次数失败:" + paramAnonymousException);
      }

      public void onResponse(String paramAnonymousString)
      {
        Gson localGson = new Gson();
        try
        {
          localGetDrawTimesBean = (GetDrawTimesBean)localGson.fromJson(paramAnonymousString, GetDrawTimesBean.class);
          if (localGetDrawTimesBean == null)
            return;
        }
        catch (Exception localException)
        {
          GetDrawTimesBean localGetDrawTimesBean;
          do
          {
            while (true)
            {
              localException.printStackTrace();
              localGetDrawTimesBean = null;
            }
            if (localGetDrawTimesBean.getFlag() == 0)
            {
              TiXianActivity.this.myDialog1.setMessage(localGetDrawTimesBean.getMsg());
              TiXianActivity.this.myDialog1.show();
              TiXianActivity.this.myDialog1.btn_confirm.setOnClickListener(new View.OnClickListener()
              {
                public void onClick(View paramAnonymous2View)
                {
                  TiXianActivity.this.myDialog1.dismiss();
                  TiXianActivity.this.closeWindowSoftInput(TiXianActivity.this.withdraw_money);
                  TiXianActivity.this.closeWindowSoftInput(TiXianActivity.this.withdraw_password);
                  CustomApplication.app.finishActivity(TiXianActivity.this);
                }
              });
              return;
            }
            if (localGetDrawTimesBean.getFlag() == -2)
            {
              TiXianActivity.this.showDownWireDialog();
              return;
            }
            if (localGetDrawTimesBean.getFlag() == -3)
            {
              TiXianActivity.this.ShowFengjinDialog();
              return;
            }
            if (localGetDrawTimesBean.getFlag() == -4)
            {
              TiXianActivity.activityStack.backToMain(MainActivity.class, TiXianActivity.this.context);
              return;
            }
          }
          while (localGetDrawTimesBean.getFlag() != 1);
          LogUtils.d("获取成功", "getDrawTimesBean-result:" + TiXianActivity.this.result);
          String str1 = localGetDrawTimesBean.getLefttimes();
          String str2 = localGetDrawTimesBean.getTotaltimes();
          TiXianActivity.this.tv_now_have_time.setText(str1);
          TiXianActivity.this.tv_one_day_time.setText(str2);
          try
          {
            double d = 100.0D * Double.parseDouble(localGetDrawTimesBean.getRate());
            int i = Integer.parseInt(new DecimalFormat("0").format(d));
            TiXianActivity.this.tv_shouxu.setText(i + "%");
            return;
          }
          catch (NumberFormatException localNumberFormatException)
          {
            localNumberFormatException.printStackTrace();
          }
        }
      }
    });
  }

  public void getUserAmount()
  {
    if (CustomApplication.app.userBaseBean != null)
      this.guid = CustomApplication.app.userBaseBean.getGuid();
    HashMap localHashMap = new HashMap();
    localHashMap.put("guid", this.guid);
    LogUtils.d(this.TAG, "URL:" + AppConstants.URL_GET_USER_AMOUNT);
    RequestNet.get(this.context, AppConstants.URL_GET_USER_AMOUNT, localHashMap, new StringCallback()
    {
      public void onError(Call paramAnonymousCall, Exception paramAnonymousException)
      {
        LogUtils.e(TiXianActivity.this.TAG, "获取失败,getUserAmount-result:" + paramAnonymousException);
      }

      public void onResponse(String paramAnonymousString)
      {
        LogUtils.d(TiXianActivity.this.TAG, "result:" + paramAnonymousString);
        Gson localGson = new Gson();
        try
        {
          localBaseDataObject = (BaseDataObject)localGson.fromJson(paramAnonymousString, BaseDataObject.class);
          if (localBaseDataObject == null)
            return;
        }
        catch (Exception localException)
        {
          BaseDataObject localBaseDataObject;
          do
          {
            while (true)
            {
              localException.printStackTrace();
              localBaseDataObject = null;
            }
            if (localBaseDataObject.getFlag() == 0)
            {
              UiUtil.showToast(TiXianActivity.this.context, localBaseDataObject.getMsg());
              return;
            }
            if (localBaseDataObject.getFlag() == -2)
            {
              TiXianActivity.this.showDownWireDialog();
              return;
            }
            if (localBaseDataObject.getFlag() == -3)
            {
              TiXianActivity.this.ShowFengjinDialog();
              return;
            }
            if (localBaseDataObject.getFlag() == -4)
            {
              TiXianActivity.activityStack.backToMain(MainActivity.class, TiXianActivity.this.context);
              return;
            }
          }
          while (localBaseDataObject.getFlag() != 1);
          TiXianActivity.this.result = localBaseDataObject.getResult();
        }
        try
        {
          if (TiXianActivity.this.result != null)
            CustomApplication.app.userAmount = Double.parseDouble(TiXianActivity.this.result);
          LogUtils.d("获取成功", "getUserAmount()-result:" + TiXianActivity.this.result);
          TiXianActivity.this.et_leave_money.setText("您的余额为" + TiXianActivity.this.result + "元宝");
          return;
        }
        catch (NumberFormatException localNumberFormatException)
        {
          while (true)
            localNumberFormatException.printStackTrace();
        }
      }
    });
  }

  protected void onCreate(Bundle paramBundle)
  {
    super.onCreate(paramBundle);
    setContentView(2130903085);
    this.btn_tixian = ((ImageView)findViewById(2131099982));
    this.btn_tixian.setOnClickListener(this.onClickListener);
    this.et_leave_money = ((TextView)findViewById(2131099976));
    this.tv_one_day_time = ((TextView)findViewById(2131099977));
    this.tv_now_have_time = ((TextView)findViewById(2131099978));
    this.tv_shouxu = ((TextView)findViewById(2131099979));
    this.bank_number = ((TextView)findViewById(2131099974));
    this.user_name = ((TextView)findViewById(2131099973));
    this.bank_name = ((TextView)findViewById(2131099975));
    Intent localIntent = getIntent();
    String str1 = localIntent.getStringExtra("accountholder");
    String str2 = localIntent.getStringExtra("bankcardid");
    String str3 = localIntent.getStringExtra("bankname");
    this.paypass = localIntent.getStringExtra("paypass");
    this.bank_number.setText("(" + str2 + ")");
    this.user_name.setText(str1);
    this.bank_name.setText(str3);
    this.withdraw_money = ((EditText)findViewById(2131099980));
    this.withdraw_money.addTextChangedListener(this.textWatcher);
    this.withdraw_password = ((EditText)findViewById(2131099981));
    CustomApplication.app.addActivity(this);
    this.context = this;
    setTitle(8, 0, 2130837809, "提现", 0, 8, 8, 0, true);
    getUserAmount();
    this.myDialog1 = new MyDialog1(this.context);
    GetDrawTimes();
  }

  protected void onDestroy()
  {
    super.onDestroy();
  }

  protected void onPause()
  {
    super.onPause();
    closeWindowSoftInput(this.withdraw_money);
    closeWindowSoftInput(this.withdraw_password);
  }

  @SuppressLint({"NewApi"})
  public void setTitle(int paramInt1, int paramInt2, int paramInt3, String paramString, int paramInt4, int paramInt5, int paramInt6, int paramInt7, boolean paramBoolean)
  {
    View localView = findViewById(2131099716);
    if (paramBoolean)
      localView.setVisibility(0);
    while (true)
    {
      ((TextView)localView.findViewById(2131099701)).setText(paramString);
      ((TextView)localView.findViewById(2131099700)).setVisibility(paramInt1);
      ImageView localImageView = (ImageView)localView.findViewById(2131099699);
      localImageView.setVisibility(paramInt2);
      localImageView.setOnClickListener(this.onClickListener);
      localImageView.setImageResource(paramInt3);
      TextView localTextView = (TextView)localView.findViewById(2131099702);
      localTextView.setVisibility(paramInt5);
      localTextView.setOnClickListener(this.onClickListener);
      this.iv_title_right = ((ImageView)localView.findViewById(2131099704));
      this.iv_title_right.setVisibility(paramInt6);
      this.iv_title_right.setOnClickListener(this.onClickListener);
      this.iv_title_right.setImageResource(paramInt7);
      return;
      localView.setVisibility(8);
    }
  }
}

/* Location:           C:\Users\user\Desktop\dd28_pcdd720\classes_dex2jar.jar
 * Qualified Name:     com.hsc.yalebao.tabMine.TiXianActivity
 * JD-Core Version:    0.6.2
 */